<%@ tag pageEncoding="UTF-8" %>
<%@ include file="inc/taglibs.jsp" %>
<%@ tag import="org.apache.commons.beanutils.BeanUtils" %>	
<%@ tag import="com.pearlsoft.util.StringUtils" %>
<%@ tag import="com.pearlsoft.ui.core.PageContextUtils" %>

<%-- 通用属性  --%>
<%@ attribute rtexprvalue="true" required="false" name="var"%>
<%@ attribute rtexprvalue="true" required="false" name="id"%>
<%@ attribute rtexprvalue="true" required="false" name="config" 
	description="如果为true，只输出配置项，如果为false，输出内容如new cmpclass(config)，默认为false"%>
<%@ attribute rtexprvalue="true" required="false" name="disabled"%>
<%@ attribute rtexprvalue="true" required="false" name="hidden"%>
<%@ attribute rtexprvalue="true" required="false" name="renderTo"%>
<%@ attribute rtexprvalue="true" required="false" name="scripts"%>
<%@ attribute rtexprvalue="true" required="false" name="styles"%>
<%@ attribute rtexprvalue="true" required="false" name="width" %>
<%@ attribute rtexprvalue="true" required="false" name="height" %>

<%-- 扩展属性  --%>
<%@ attribute rtexprvalue="true" required="true" name="handlerName" description="handlerName的名称" %>
<%@ attribute rtexprvalue="true" required="false" name="handlerMethod"  description="handlerMethod的名称,默认为handler"%>
<%@ attribute rtexprvalue="true" required="true" name="datasetName" description="datasetName的名称" %>
<%@ attribute rtexprvalue="true" required="false" name="conditions"  description="查询条件数组 如:[{fieldName:'id',value:'001'}]"%>

<%@ attribute rtexprvalue="true" required="false" name="model" description="store中的model" %>
<%@ attribute rtexprvalue="true" required="false" name="fields" description="model的字段数组" %>
<%@ attribute rtexprvalue="true" required="false" name="autoLoad" description="是否自动加载，默认为是" %>
<%@ attribute rtexprvalue="true" required="false" name="title" %>
<%@ attribute rtexprvalue="true" required="false" name="autoSync" description="是否同步，默认为false"   %>
<%@ attribute rtexprvalue="true" required="false" name="rootVisible" description="根节点是否可见,默认为不可见"%>
<%@ attribute rtexprvalue="true" required="false" name="rootText" description="根节点名称,默认为Root"   %>
<%@ attribute rtexprvalue="true" required="false" name="rootID" description="根节点ID,默认为0" %>


<%
	init();
%>
<plst:cmpResources scripts="${scripts}" styles="${styles}" >
	<plsc:topScript>
		<plsc:component name="Pearlsen.PTreeStore" var="${cmpID}_store">
			<plsc:attr name="autoLoad" type="boolean"  test="${!empty(autoLoad)}">${autoLoad}</plsc:attr>
			<plsc:attr name="autoSync" type="boolean" test="${!empty(autoSync)}">${autoSync}</plsc:attr>
			<plsc:attr name="model" type="string" test="${!empty(model)}" >${model}</plsc:attr>
			<plsc:attr name="fields" type="direct" test="${!empty(fields)}" >${fields}</plsc:attr>
			<plsc:attr name="handlerName" test="${!empty(handlerName)}" type="string">${handlerName}</plsc:attr>
			<plsc:attr name="handlerMethod" test="${!empty(handlerMethod)}" type="string">${handlerMethod}</plsc:attr>
			<plsc:attr name="datasetName" test="${!empty(datasetName)}" type="string">${datasetName}</plsc:attr>
			<plsc:attr name="conditions" test="${!empty(conditions)}" type="direct">${conditions}  </plsc:attr>
			<plsc:attr name="defaultRootId"  type="string">${empty(rootID)?"0":rootID }</plsc:attr>
			<plsc:attr name="root">
			  	<plsc:value>
					<plsc:attr name="text" type="string">${empty(rootText)?"Root":rootText}</plsc:attr>
					<plsc:attr name="id"  type="string">${empty(rootID)?"0":rootID}</plsc:attr>
					<plsc:attr name="expanded"  type="boolean">true</plsc:attr>
			  	</plsc:value>
		  	</plsc:attr>
			<plsc:listeners>
				<plsc:handler name="beforeload" funcName="Pls.TAG.COMMON.treeStoreBeforeload"></plsc:handler>
			</plsc:listeners>


		</plsc:component>

	</plsc:topScript>
	<plsc:component name="Pearlsen.tree.PPanel" var="${var}" config="${config}"  >
		<plsc:attr name="id" test="${!empty(id)}">${id}</plsc:attr>
		<plsc:attr name="xtype" test="${config == true}">ptreepanel</plsc:attr>
		<plsc:attr name="disabled" test="${!empty(disabled)}" type="boolean" >${disabled}</plsc:attr>
		<plsc:attr name="hidden" test="${!empty(hidden)}" type="boolean" >${hidden}</plsc:attr>		
		<plsc:attr name="renderTo" test='<%=StringUtils.isNotEmpty(renderTo)%>'
			type='<%= StringUtils.getRenderType(renderTo)%>'>${renderTo}</plsc:attr>
		<plsc:attr name="width" test="${!empty(width)}"  type="int" >${width}</plsc:attr>
		<plsc:attr name="height" test="${!empty(height)}"  type="int" >${height}</plsc:attr>
		<plsc:attr name="title" test="${!empty(title)}"  type="string" >${title}</plsc:attr>
		<%-- UI特性  --%>
		<%-- 扩展属性  --%>
		<plsc:attr name="store" type="direct">${cmpID}_store</plsc:attr>
		<plsc:attr name="rootVisible" type="boolean">${empty(rootVisible)?false:rootVisible}</plsc:attr>
		<jsp:doBody/>
	</plsc:component>
</plst:cmpResources>

<%!
public void init (){
	this.getJspContext().setAttribute("cmpID", 
			PageContextUtils.getCmpId(id, this.getJspContext()),PageContext.REQUEST_SCOPE);
}
%>

